home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / System Services / FalseAlarm-2 / FalseAlarm.text < prev    next >
Encoding:
Text File  |  1994-07-08  |  3.9 KB  |  174 lines  |  [TEXT/MPS ]

  1. /*
  2.  
  3. Copyright © 1994 Apple Computer, Inc. All Rights Reserved.
  4. author Mike Engber
  5.  
  6. FalseAlarm-2
  7.  
  8. version history
  9.  
  10. v1 - initial release
  11.  
  12. v2
  13.   - uses new alarm stub
  14.   - bug fix - if the FalseAlarm app was closed when the alarm went
  15.     off, DoAlarm blindly sent messages to a child view (that didn't
  16.     exist since FalseAlarm was closed)
  17.  
  18.  */
  19.  
  20. constant kAppSymbol := '|FalseAlarm:PIEDTS|;
  21. constant kAppString := "FalseAlarm:PIEDTS";
  22.  
  23. refNum := OpenResFileX( Home & "FalseAlarm.rsrc"); 
  24.   DefConst('kAlarmSound,GetSound("dadadadadada"));
  25. CloseResFileX(refNum);
  26.  
  27. DefConst('kAlarmFn,
  28. func()
  29.   begin
  30.     if GetRoot().(kAppSymbol) exists then
  31.       GetRoot().(kAppSymbol):DoAlarm()
  32.     else
  33.       GetRoot():Notify(kNotifyAlert,"FalseAlarm","App not installed.");
  34.   end
  35. );
  36.  
  37. DefConst('kPopUpList,[
  38. { item:  "1 minute",  dt:   1, },
  39. { item:  "2 minutes", dt:   2, },
  40. { item:  "5 minutes", dt:   5, },
  41. { item: "10 minutes", dt:   10,},
  42. ]);
  43.  
  44. "Reg the llama";
  45.  
  46. // ---- End Project Data ----
  47.  
  48.  
  49. // ---- File FalseAlarm.t ----
  50.  
  51. // Before Script for "FalseAlarmBase"
  52. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  53.  
  54. FalseAlarmBase :=
  55.    {title: "False Alarm",
  56.     viewBounds: {left: 1, top: 10, right: 203, bottom: 246},
  57.     viewJustify: 16,
  58.     pickActionScript:
  59.       func(index)
  60.       begin
  61.         local time := Time() + kPopUpList[index].dt;
  62.         call kAddAlarmFunc with (kAppString,time,nil,kAlarmFn,[]);
  63.         AlarmButton:Close();
  64.         TimeArea:Open();
  65.         SetValue(alarmTime,'text,HourMinute(time));
  66.         SetValue(curTime,'text,HourMinute(Time()) && TimeInSeconds() MOD 60);
  67.         :SetUpIdle(1000);
  68.       end,
  69.     DoAlarm:
  70.       func()
  71.       begin
  72.         PlaySound(kAlarmSound);
  73.         if call kViewIsOpenFunc with (self) then
  74.           begin
  75.             AlarmButton:Open();
  76.             TimeArea:Close();
  77.             :SetUpIdle(0);
  78.           end
  79.       end,
  80.     viewIdleScript:
  81.       func()
  82.       begin
  83.         SetValue(curTime,'text,HourMinute(Time()) && TimeInSeconds() MOD 60);
  84.         1000;
  85.       end,
  86.     _proto: protoApp,
  87.     debug: "FalseAlarmBase"
  88.    };
  89.  
  90. alarmButton := /* child of FalseAlarmBase */
  91.    {text: "Set Alarm",
  92.     buttonClickScript:
  93.       func()
  94.       begin
  95.         DoPopUp(kPopUpList,:LocalBox().right,0,GetRoot().(kAppSymbol));
  96.         //see the PickActionScript of FalseAlarmBase for the code that sets the alarm
  97.       end,
  98.     viewBounds: {left: 0, top: 34, right: 100, bottom: 54},
  99.     viewJustify: 8388630,
  100.     _proto: protoTextButton,
  101.     debug: "alarmButton"
  102.    };
  103. // View alarmButton is declared to FalseAlarmBase
  104.  
  105.  
  106.  
  107. timeArea := /* child of FalseAlarmBase */
  108.    {viewFlags: 0,
  109.     viewFormat: nil,
  110.     viewBounds: {left: 6, top: 64, right: 198, bottom: 184},
  111.     viewclass: 74,
  112.     debug: "timeArea"
  113.    };
  114. // View timeArea is declared to FalseAlarmBase
  115.  
  116. _view000 := /* child of timeArea */
  117.    {text: "current time",
  118.     viewBounds: {left: 8, top: 16, right: 88, bottom: 32},
  119.     _proto: protoStaticText
  120.    };
  121.  
  122.  
  123.  
  124. _view001 := /* child of timeArea */
  125.    {text: "alarm time",
  126.     viewBounds: {left: 8, top: 40, right: 88, bottom: 56},
  127.     _proto: protoStaticText
  128.    };
  129.  
  130.  
  131.  
  132. curTime := /* child of timeArea */
  133.    {text: "cur time",
  134.     viewBounds: {left: 100, top: 16, right: 180, bottom: 32},
  135.     _proto: protoStaticText,
  136.     debug: "curTime"
  137.    };
  138. // View curTime is declared to FalseAlarmBase
  139.  
  140.  
  141.  
  142. alarmTime := /* child of timeArea */
  143.    {text: "alarm time",
  144.     viewBounds: {left: 100, top: 40, right: 180, bottom: 56},
  145.     _proto: protoStaticText,
  146.     debug: "alarmTime"
  147.    };
  148. // View alarmTime is declared to FalseAlarmBase
  149.  
  150.  
  151.  
  152. _view002 := /* child of timeArea */
  153.    {text: "Kill Alarm",
  154.     buttonClickScript:
  155.       func()
  156.       begin
  157.         call kRemoveAlarmFunc with (kAppString);
  158.         GetRoot().(kAppSymbol):DoAlarm();
  159.       end,
  160.     viewBounds: {left: 50, top: 74, right: 134, bottom: 94},
  161.     _proto: protoTextButton
  162.    };
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172. // ---- Beginning of section for non used Layout files ----
  173.  
  174. // End of output